/**
 * 1. body改变背景颜色为蓝色blue
 * 2.创建一个方形的盒子 背景为黑色 宽高皆为400px；
 * 3. 创建一个小球在里面运动
 * 1获取小球的left top 
 * 
 */
var zhBall = document.getElementsByClassName('green')[0];
zhBall.style.left = 0;
zhBall.style.top = 0;
var num = 1;
var num1 = 2;
setInterval(function() {
    if (parseInt(zhBall.style.top) > 449) {

        num1 = -Math.floor(Math.random() * 2 + 1);

    } else if (parseInt(zhBall.style.top) < 0) {
        num1 = -num1
    }
    if (parseInt(zhBall.style.left) > 450) {
        num = -Math.floor(Math.random() * 3 + 1);
    } else if (parseInt(zhBall.style.left) < 0) {
        num = -num
    }
    zhBall.style.left = parseInt(zhBall.style.left) + num + "px";
    zhBall.style.top = parseInt(zhBall.style.top) + num1 + "px";


}, 5)